<template>
    <div>
        <el-form ref="ruleFormRefa" :model="formInlines" label-width="120px" :rules="formRules" label-position="top"
            class="demo-ruleForm">
            <el-row :gutter="30">
                <el-col :value="24" :xs="24" :sm="24">
                    <el-form-item label="确认结果" prop="confirm">
                        <el-radio-group v-model="formInlines.confirm" @change="changeconfirm">
                            <el-radio :value="1" size="large">真实</el-radio>
                            <el-radio :value="2" size="large">误报</el-radio>
                            <el-radio :value="3" size="large">测试</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
                <el-col :value="24" :xs="24" :sm="24" v-if="formInlines.confirm==1">
                    <el-form-item label="处理结果" prop="dealStatus">
                        <el-radio-group v-model="formInlines.dealStatus">
                            <el-radio :value="1">无需处理</el-radio>
                            <el-radio :value="2">工单处理</el-radio>
                            <el-radio :value="3">已处理</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>

                <el-col :value="24" :xs="24" :sm="24" v-if="formInlines.dealStatus == 2">
                    <el-form-item label="派发方式" prop="sellMethod">
                        <el-radio-group v-model="formInlines.sellMethod">
                            <el-radio v-for="item in WORKORDER_DISPATCH_TYPE" :key="item.value" :value="item.value">
                                {{ isNullOrEmpty( item.label ) }}
                            </el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>

                <el-col :value="12" :xs="12" :sm="12"
                    v-if="formInlines.sellMethod === 1 && formInlines.dealStatus == 2">
                    <el-form-item label="工单流程" prop="processId">
                        <processesselect v-model="formInlines.processId" :project-id="projectId" clearable placeholder="请选择工单流程"
                        :teleported="false"   :style="{ width: '100%' }">
                        </processesselect>
                    </el-form-item>
                </el-col>

                <el-col :value="12" :xs="12" :sm="12"
                    v-if="formInlines.sellMethod === 2 && formInlines.dealStatus == 2">
                    <el-form-item label="处理人" prop="handleUid">
                        <authorizeuser v-model="formInlines.handleUid" clearable :isid="1" :project-id="projectId"
                        :teleported="false"  placeholder="请选择处理人" :style="{ width: '100%' }" />
                    </el-form-item>
                </el-col>

                <el-col :value="12" :xs="12" :sm="12" v-if="formInlines.sellMethod == 2 && formInlines.dealStatus == 2">
                    <el-form-item label="通知方式" prop="noticeType">
                        <el-checkbox-group v-model="formInlines.noticeType">
                            <el-checkbox v-for="item in WORKORDER_NOTICE_TYPE" :key="item.value" :value="item.value">
                                {{ isNullOrEmpty( item.label ) }}
                            </el-checkbox>
                        </el-checkbox-group>
                    </el-form-item>
                </el-col>

                <el-col :value="24" :xs="24" :sm="24" v-if="formInlines.confirm==1">
                    <el-form-item label="处理意见" prop="dealView">
                        <el-input v-model="formInlines.dealView" :autosize="{ minRows: 4 }" type="textarea" clearable
                            placeholder="请输入处理意见" />
                    </el-form-item>
                </el-col>

            </el-row>
        </el-form>
    </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import {isNullOrEmpty} from '@/utils/functions'
import type { FormRules } from "element-plus";
import authorizeuser from "@/components/select/authorizeuser/authorizeuserScreen.vue";
import processesselect from "@/components/select/processesselect/processesSelectScreen.vue";
import {
    WORKORDER_TYPES,
    WORKORDER_DISPATCH_TYPE,
    WORKORDER_NOTICE_TYPE
} from "@/constant/workorder-mangenment";
type FormProps = {
    id: number;
    projectId: number;
    formInlines: any;
};
const props = withDefaults(defineProps<FormProps>(), {
    id: 0,
    projectId: 0,
    formInlines: {
        confirm: null,
        dealStatus: null,
        dealView: null,
        sellMethod: null,
        processId: null,
        handleUid: null,
        noticeType: []
    }
});
const changeconfirm=(e)=>{
  if(e!==1){
    props.formInlines.dealStatus=1
  }
}
const ruleFormRefa = ref();
const formRules = reactive(<FormRules>{
    dealView: [{ required: true, message: "请输入处理意见", trigger: "blur" }],
    dealStatus: [{ required: true, message: "请选择处理结果", trigger: "blur" }],
    confirm: [{ required: true, message: "请选择确认结果", trigger: "blur" }]
});
function getRef() {
    return ruleFormRefa.value;
}
defineExpose({ getRef });
</script>